class Solution
{
public:
    vector<string> validStrings(int n)
    {
        vector<string> result;
        function<void(string)> f = [&](string s)
        {
            if (s.size() == n)
            {
                result.push_back(s);
                return;
            }
            if (s.back() == '0')
            {
                f(s + "1");
            }
            else
            {
                f(s + "0");
                f(s + "1");
            }
        };

        f("0");
        f("1");
        return result;
    }
};